<?php

namespace App\Models;

use App\Models\Contract\SerializeDatetime;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Adreward extends Model
{
    use HasFactory, SerializeDatetime;

    protected $fillable = [
        'user_id', 'amount', 'real_amount', 'real_money', 'user_money', 'received_at'
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }
    public function parent()
    {
        return $this->hasOne(User::class, 'id','parent_id');
    }

    public function member()
    {
        return $this->hasOne(GroupMember::class, 'user_id', 'user_id');
    }
    public function details()
    {
        return $this->hasMany(AdrewardDetail::class);
    }
}
